home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / comp / divide.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  932 b   |  38 lines

  1. /*
  2.                             D I V I D E . C
  3. */
  4.  
  5. #include "iccomp.h"
  6.  
  7. ESTRUC_ *divide (lval, rval)
  8.     ESTRUC_
  9.         *lval,
  10.         *rval;
  11. {
  12.     if (test_binop(op_div, lval, rval))
  13.         return (lval);                      /* test for correct types */
  14.  
  15.     btoi(lval);                             /* convert pending booleans */
  16.     btoi(rval);
  17.  
  18.     if (conflict(lval, rval, op_div))       /* test type conflict */
  19.         return(lval);
  20.  
  21.     if (test_type(rval, e_const))
  22.     {
  23.         if (!rval->evalue)                  /* expression / 0: not allowed */
  24.         {
  25.             semantic("division by 0: undefined");
  26.             clearbin(lval, rval);
  27.             return (lval);
  28.         }
  29.         if (test_type(lval, e_const))
  30.         {
  31.             lval->evalue /= rval->evalue;
  32.             return (lval);
  33.         }
  34.     }
  35.     defcode(lval, rval, op_div);
  36.     return (lval);                          /* return new expression */
  37. }
  38.